using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class AudioController : MonoBehaviour
{
    public List<AudioSource> AudioPlayers;
    public Button audiocontrol;
    public Sprite on;
    public Sprite off;
    static bool isPlayer = true;

    // Start is called before the first frame update
    void Start()
    {
        if (isPlayer)
        {
            foreach (var temp in AudioPlayers)
            {
                temp.GetComponent<AudioSource>().volume = 1;
            }
        }
        else
        {
            audiocontrol.image.sprite = off;
            foreach (var temp in AudioPlayers)
            {
                temp.GetComponent<AudioSource>().volume = 0;
            }
        }
        
    }

    public void clickedAudio()
    {
        transform.GetComponent<AudioSource>().Play();
        if (isPlayer)
        {   
            isPlayer = false;
            foreach(var temp in AudioPlayers)
            {
                
                temp.volume = 0;
            }
        }
        else
        {
            isPlayer = true;
            foreach (var temp in AudioPlayers)
            {
                temp.volume = 1;
                
            }
        }
    }
}
